﻿@using Projectmanagement.Entity
@using ProjectManagement.Models 
@{
    ViewBag.Title = "TaskTemplate";
}

@(Html.Telerik().Grid<_TaskTemplate>()
    .Name("TaskTemplate")
    .DataKeys(keys => { keys.Add(item => item.ID); })
    .ClientEvents(events => events.OnEdit("onEdit"))
    .ToolBar(commands => commands.Insert())
    .DataBinding(dataBinding =>
    {
        dataBinding.Ajax()
            .Select("_SelectIndex", "TaskTemplate")
            .Insert("_InsertAjaxEditing", "TaskTemplate")
            .Update("_SaveAjaxEditing", "TaskTemplate")
            .Delete("_DeleteAjaxEditing", "TaskTemplate");
    })
    .Columns(columns =>
    {
        columns.Bound(item => item.Name).Width(360);
        columns.Bound(item => item.DateCount).Width(120);
        columns.Bound(item => item.Duration).Width(120);
        columns.Bound(item => item.RolePM).Width(140);
        //columns.Bound(item => item.Complement).Width(120);
        columns.Command(commands =>
        {
            commands.Edit();
            commands.Delete();
        }).Title("操作").Width(200);
    })
    .Editable(editing => editing.Mode(GridEditMode.PopUp))
    .Pageable(paging=>paging.Style(GridPagerStyles.Status).PageOnScroll(true).PageSize(50))
    .Scrollable(c => c.Height("570px"))
    .Resizable(resizing => resizing.Columns(true))
        .Sortable(sorting => sorting
        .OrderBy(order =>
        {
            order.Add(o => o.DateCount).Descending();
        }))
)

<script type="text/javascript">
    function onEdit(e) {
        var taskId = e.dataItem["ID"];
        if (taskId == 0) {
        } else {
            $("#legendTitle").html("编辑任务模板");
        }
    }
</script>
